import React, { Component } from 'react';
import { Calendar } from 'antd-mobile';
import { formatDate } from '@/assets/js/methods'
import "./OrderProgress.scss"
const now = new Date();
class RepairServe extends Component {
	originbodyScrollY = document.getElementsByTagName('body')[0].style.overflowY;
	constructor() {
		super()
		this.state = {
			show: false,
			config: {
				type: 'one'
			},
		}
	}
	onSelectHasDisableDate = (dates) => {
		console.warn('onSelectHasDisableDate', dates);
	}

	onConfirm = (startTime) => {
		console.log(startTime.getTime())
		document.getElementsByTagName('body')[0].style.overflowY = this.originbodyScrollY;
		this.setState({
			show: false,
			startTime: formatDate(startTime.getTime())
		});
	}

	onCancel = () => {
		document.getElementsByTagName('body')[0].style.overflowY = this.originbodyScrollY;
		this.setState({
			show: false,
			startTime: undefined,
			endTime: undefined,
		});
	}
	componentDidMount() {
		document.getElementsByTagName('title')[0].innerHTML = '报修服务'
		this.setState({
			startTime: formatDate(new Date().getTime())
		})
	}
	render() {
		let height = window.screen.height
		return (
			<div className="other-page OrderProgress" style={{ minHeight: height + 'px' }}>
				<div className="topbar flex y-center space-between">
					<span className="flex y-center">
						<span>待维护</span>
						<img src={require('../../images/switch.png')} alt="" className="ml10" />
					</span>
					<span className="flex y-center">
						<span>{this.state.startTime}</span>
						<img src={require('../../images/calendar.png')}
							alt=""
							className="ml20"
							onClick={() => {
								document.getElementsByTagName('body')[0].style.overflowY = 'hidden';
								this.setState({
									show: true
								});
							}} />
					</span>
				</div>
				<div className="card card2 pb18">
					<div className="flex space-between row y-center">
						<span>净水器报修</span>
						<span className="small-white-but">派单</span>
					</div>
					<div className="border-b mt8"></div>

					<div className="row row2">
						<span className="left">订单信息：</span>
						<span>12345621</span>
					</div>

					<div className="row row2">
						<span className="left">详细地址：</span>
						<span>北京市朝阳区立水桥</span>
					</div>
					<div className="flex space-between row mt18">
						<span>订单距离：5km</span>
						<span className="red">3天到期</span>
					</div>
				</div>

				<Calendar
					{...this.state.config}
					visible={this.state.show}
					onCancel={this.onCancel}
					onConfirm={this.onConfirm}
					onSelectHasDisableDate={this.onSelectHasDisableDate}
					getDateExtra={this.getDateExtra}
					defaultDate={now}
					minDate={new Date(+now - 5184000000)}
					maxDate={new Date(+now + 31536000000)}
				/>
			</div>
		);
	}
}

export default RepairServe;